﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="viewport" content="width=device-width,user-scalable=0"/>
    <meta charset="UTF-8">
    <title>BD健身</title>
    <script src="/api/js/fontSize.js"></script>
    <link rel="stylesheet" href="/api/css/bootstrap.min.css">
    <link rel="stylesheet" href="/api/css/reset.css">
    <link rel="stylesheet" href="/api/css/my_main.css">
    <script src="/assets/js/jquery.min.js"></script>
    <script src="/assets/layui.js""></script>
</head>
<body>
<div class="register">

        <div class="regTitle">
            <h2>设置新密码</h2>
        </div>
        <div class="reg_form">

            <form action="#" class="form-horizontal">
                <div class="form-group">
                <input type="hidden" name="telphone" value="{$data}" id='tel'>
                    <div class="regText">
                        <p>设置密码</p>
                    </div>
                    <input type="password" name="password" class="form-control pw" placeholder="请输入6~16位密码" id='pwd'>
                </div>
                <div class="form-group">
                    <div class="regText">
                        <p>确认密码</p>
                    </div>
                    <input type="password" name="pwd2" class="form-control pw" placeholder="请输入确认密码" id='pwd2'>
                </div>

                <div class="container">
                    <a href="javascript:" class="btn btn-primary" id="sub"><span>确定</span></a>

                </div>


            </form>
        </div>



</div>
<script type="text/javascript">
$(function(){
	var layer;
	 layui.use('layer', function(){
	      layer = layui.layer;
	  
	}); 
	$('#pwd').blur(function(){
		var telphone=$('#tel').val();
		var password=$('#pwd').val();
		if(password.length==0){
			layer.msg('密码不能为空',{icon:5});
		}
		var url="{:url('api/user/checkpasswd')}";
		$.get(url,{telphone:telphone,password:password},function(res){
			var obj=eval('(' +res +')');
			var status=obj.status;
			var info=obj.info;
			if(status==0){
				layer.msg(info,{icon:5});
			}
		});
	});
	$('#pwd2').blur(function(){
		var pwd1=$('#pwd').val();
		var pwd2=$('#pwd2').val();
		if(pwd1!=pwd2){
			layer.msg('俩次输入的密码不一样',{icon:5});
		}
	});
	$('#sub').click(function(){
		var data=$('form').serialize();
		var url="{:url('api/user/updatePwd')}";
		$.post(url,data,function(res){
			var obj=eval('('+ res +')');
			var status=obj.status;
			var data=obj.data;
			var info=obj.info;
			if(status==-1){
				layer.msg(info,{icon:5});
			}else if(status==1){
				layer.msg(info,{icon:5});
			}else if(status==2){
				layer.msg(info,{icon:5});
			}else if(status==3){
				layer.msg(info,{icon:6},function(){
					window.location.href=data;
				})
			}else{
				layer.msg(info,{icon:5});
			}
		});
		
	});
})





</script>

</body>
</html>